import { TrackOpTypes, TriggerOpTypes } from "./utils/operations";

let activeEffect = true;

export const pauseTracking = () => {
  activeEffect = false;
};

export const resumeTracking = () => {
  activeEffect = true;
};
//依赖收集
export const track = (target, type, key) => {
  if (!activeEffect) {
    //如果有需要暂停的,则终止收集
    return;
  }
  if (type === TrackOpTypes.ITERATE) {
    console.log(`%c依赖收集 ${type}`, "color:red");
    return;
  }
  console.log(`%c依赖收集 ${type}`, "color:red", key);
};

//派发更新
export const trigger = (target, type, key) => {
  console.log(`%c派发更新 ${type}`, "color:blue", key);
};
